package com.ytkj.tradeserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.ytkj.tradeserver.dao.IArticleinfoDao;
import com.ytkj.tradeserver.entity.Articleinfo;
import com.ytkj.tradeserver.entity.StoreArticlesVO;
import com.ytkj.tradeserver.model.PageBean;
import com.ytkj.tradeserver.service.iservice.IArticleinfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/4/13.
 */
@Service
public class ArticleinfoService implements IArticleinfoService{

    @Resource
    IArticleinfoDao articleinfoDao;

    public PageBean<Articleinfo> queryAllArticles(String url,Articleinfo info,PageBean pageBean) {
        PageHelper.startPage(pageBean.getPageNum(), pageBean.getPageSize());
        List<Articleinfo> list =  articleinfoDao.queryAllArticles(info);
        return new PageBean<>(list,url);
    }

    public int addArticle(Articleinfo info){
       return articleinfoDao.addArticle(info);
    }

    public Articleinfo querySingleArticle(Articleinfo info){
        return articleinfoDao.querySingleArticle(info);
    }


    public int addViewsNum(int articleid) {
        return articleinfoDao.addViewsNum(articleid);
    }

    public boolean queryIsStored(StoreArticlesVO store){
        return articleinfoDao.queryIsStored(store);
    }

    public int storeLoveArticle(StoreArticlesVO store){
        return articleinfoDao.storeLoveArticle(store);
    }
}
